from django.db import models


# Create your models here.
class Contact(models.Model):
    id = models.CharField(max_length=32, primary_key=True)  # 唯一Id
    username = models.CharField(max_length=32)  # 用户名
    avatar = models.CharField(max_length=255)  # 头像
    index = models.CharField(max_length=255)  # 通讯录索引
    isGroup = models.IntegerField()  # 是否为群聊
    unread = models.IntegerField()  # 未读消息数
    lastSendTime = models.BigIntegerField()  # 最近一条消息的时间戳，13位毫秒
    lastContent = models.CharField(max_length=255)  # 最近一条消息的内容
    myId = models.IntegerField()  # 当前用户Id

    class Meta:
        db_table = "contact"


class Message(models.Model):
    id = models.CharField(max_length=32, primary_key=True)  # 唯一Id
    status = models.CharField(max_length=32)  # 消息发送的状态 going/failed/succeed
    type = models.CharField(max_length=32)  # 消息类型 file/image/text/event
    sendTime = models.BigIntegerField()  # 消息发送时间，13位毫秒
    content = models.CharField(max_length=255)  # 消息内容，如果type=file，此属性表示文件的URL地址
    fileSize = models.IntegerField()  # 文件大小
    fileName = models.CharField(max_length=255)  # 文件名称
    toContactId = models.IntegerField()  # 接收消息的联系人Id
    fromUser = models.CharField(max_length=255)  # 消息发送人的信息 { id: , userName: , avatar: }

    class Meta:
        db_table = "message"
